package com.jcl.recruit.searchresume.mapper;

import com.jcl.recruit.searchresume.model.SearchResumeProject;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author 刘明新
 * @date 2018/8/14 下午4:01
 */
public interface SearchResumeProjectMapper {

    @Select({
            "select * from search_resume_project where resume_id = #{id}"
    })
    List<Map<String,Object>> selectResumeProjectByResumeId(@Param("id") Integer id);

    @Select({
            "select * from search_resume_project where resume_id = #{id}"
    })
    List<SearchResumeProject> selectSearchResumeProjectList(@Param("id") Integer id);

    @Insert({
            "<script>",
            "insert into search_resume_project (resume_id,projectname,duty,description,start_date,end_date)",
            "values",
            "<foreach collection='list' item='entity' index='index' separator=','>",
            "(#{entity.resumeId},#{entity.projectname},#{entity.duty},#{entity.description},#{entity.startDate},#{entity.endDate})",
            "</foreach>",
            "</script>"
    })
    int batchInsertProjects(@Param("list") List<SearchResumeProject> list);

    @Delete({
            "<script>",
            "delete from search_resume_project where resume_id in ",
            "<foreach collection='ids' item='id' separator=',' open='(' close=')' >",
            " #{id} ",
            "</foreach>",
            "</script>"
    })
    int batchDeleteByResumeIds(@Param("ids") List<Integer> ids);
}
